<?php

class Admin_Model_DbTable_School extends Zend_Db_Table_Abstract {
	
	protected $_name = 'school';
	
	protected $_dependentTables = array('Admin_Model_DbTable_schooldept');
	
	/**
	 * Function: addSchool
	 * @param unknown_type $name
	 * This function governs the addition of a school into the database system
	 */
	public function addSchool($name){
	
		$data = array (
		 'name' => $name,
		);
		$this->insert($data);
		
	}
	
	/**
	 * 
	 */
	public function checkAddition($name){
		
		$result = $this->fetchAll('name = '.$name);
	}
	/**
	 * Function: Getschools
	 * This function retrieves all the schools stored in the database
	 */
	public function getSchools(){
		
		return $this->fetchAll();
	}
	
	/**
	 * Function: deleteschool
	 * This method deletes a particular school from the database.
	 */
	public function deleteSchool($id){
		
		$this->delete('id =' . (int)$id);
	}
	
	/**
	 * Function: Edit school
	 * This function returns a specific school from the database
	 */
	
		public function getSchool($id)	{
		$id = (int)$id;
		$row = $this->fetchRow('id = ' . $id);
		if (!$row) {
		throw new Exception("Count not find row $id");
		}
		return $row->toArray();
		}
	/**
	 * Function: UpdateSchools
	 * This function updates a school record in the database
	 */
	public function updateschool($id, $schoolname){
		
		$data = array (
			'name' => $schoolname
		);
		$this->update($data, 'id =' .(int)$id);
	}
	
}